package com.hx.springboot1.controller;

import com.github.pagehelper.PageInfo;
import com.hx.springboot1.pojo.entity.TabStudent;
import com.hx.springboot1.service.StuService;
import com.hx.springboot1.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: hx
 * Date: 2021-05-22 22/47
 * Description: Nothing else
 */
@Controller
public class StuController {
    @Autowired
    StuService stuService;
    @RequestMapping("/selectStu")
    public String selectCourse(String searchName, String pageNum, String pageSize, Model model){
        PageInfo pageInfo = stuService.selectAllStu(searchName, pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "manage/stuList";
    }
    @PostMapping("/insertOrUpdateStu")
    @ResponseBody
    public ResultMsg iouStu(Integer stuId, Integer userId,
                            Integer collegeId, Integer majorId, String stuName, String stuSex){
        return stuService.insertOrUpdateStu(stuId,userId,collegeId,majorId,stuName,stuSex);
    }
    @GetMapping("/selectStuById")
    @ResponseBody
    public TabStudent sSbI(Integer id){
        return stuService.selectStuById(id);
    }
    @GetMapping("/deleteStuInfo")
    @ResponseBody
    public ResultMsg deleteStu(String SIDAndUID){
        return stuService.delStu(SIDAndUID);
    }
}
